import time
import random
import gevent
from gevent import monkey
#在有耗时操作的情况下需要
monkey.patch_all()
def work(work_name):
    for i in range(10):
        print(work_name,i)
        time.sleep(random.random())


gevent.joinall([
    gevent.spawn(work,'work1'),
    gevent.spawn(work,'work2')
])